home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.tree;
-
- import java.awt.Rectangle;
- import java.util.Enumeration;
- import java.util.Vector;
-
- class VariableHeightLayoutCache$TreeStateNode extends DefaultMutableTreeNode {
- // $FF: synthetic field
- private final VariableHeightLayoutCache this$0;
- protected int preferredWidth;
- protected int preferredHeight;
- protected int xOrigin;
- protected int yOrigin;
- protected boolean expanded;
- protected boolean hasBeenExpanded;
- protected TreePath path;
-
- public VariableHeightLayoutCache$TreeStateNode(VariableHeightLayoutCache var1, Object var2) {
- super(var2);
- this.this$0 = var1;
- }
-
- public Enumeration children() {
- return !this.isExpanded() ? DefaultMutableTreeNode.EMPTY_ENUMERATION : super.children();
- }
-
- public void collapse() {
- this.collapse(true);
- }
-
- protected void collapse(boolean var1) {
- if (this.isExpanded()) {
- Vector var2 = null;
- Enumeration var3 = ((DefaultMutableTreeNode)this).preorderEnumeration();
- var3.nextElement();
- int var4 = 0;
- boolean var5 = this.this$0.isFixedRowHeight();
- int var6;
- if (var5) {
- var6 = 0;
- } else {
- var6 = this.getPreferredHeight() + this.getYOrigin();
- }
-
- int var7 = this.getPreferredHeight();
- int var8 = var6;
- int var9 = this.getRow();
- this.expanded = false;
- if (var9 == -1) {
- this.markSizeInvalid();
- } else if (var1) {
- this.updatePreferredSize(var9);
- }
-
- if (!var5) {
- while(var3.hasMoreElements()) {
- VariableHeightLayoutCache$TreeStateNode var14 = (VariableHeightLayoutCache$TreeStateNode)var3.nextElement();
- if (VariableHeightLayoutCache.access$1(this.this$0).contains(var14)) {
- ++var4;
- if (this.this$0.treeSelectionModel != null && this.this$0.treeSelectionModel.isRowSelected(var4 + var9)) {
- if (var2 == null) {
- var2 = new Vector();
- }
-
- var2.addElement(var14.getTreePath());
- }
-
- VariableHeightLayoutCache.access$1(this.this$0).removeElement(var14);
- var6 = var14.getYOrigin() + var14.getPreferredHeight();
- }
- }
- } else {
- while(var3.hasMoreElements()) {
- VariableHeightLayoutCache$TreeStateNode var10 = (VariableHeightLayoutCache$TreeStateNode)var3.nextElement();
- if (VariableHeightLayoutCache.access$1(this.this$0).contains(var10)) {
- ++var4;
- if (this.this$0.treeSelectionModel != null && this.this$0.treeSelectionModel.isRowSelected(var4 + var9)) {
- if (var2 == null) {
- var2 = new Vector();
- }
-
- var2.addElement(var10.getTreePath());
- }
-
- VariableHeightLayoutCache.access$1(this.this$0).removeElement(var10);
- }
- }
- }
-
- if (var9 != -1 && var1 && (var4 > 0 || var7 != this.getPreferredHeight())) {
- var8 += this.getPreferredHeight() - var7;
- if (!var5 && var9 + 1 < this.this$0.getRowCount() && var8 != var6) {
- int var12 = var8 - var6;
- int var15 = var9 + 1;
-
- for(int var11 = VariableHeightLayoutCache.access$1(this.this$0).size(); var15 < var11; ++var15) {
- ((VariableHeightLayoutCache$TreeStateNode)VariableHeightLayoutCache.access$1(this.this$0).elementAt(var15)).shiftYOriginBy(var12);
- }
- }
-
- this.didAdjustTree();
- VariableHeightLayoutCache.access$8(this.this$0);
- }
-
- if (this.this$0.treeSelectionModel != null && var4 > 0 && var9 != -1) {
- if (var2 != null) {
- int var16 = var2.size();
- TreePath[] var17 = new TreePath[var16];
- var2.copyInto(var17);
- this.this$0.treeSelectionModel.removeSelectionPaths(var17);
- this.this$0.treeSelectionModel.addSelectionPath(this.getTreePath());
- } else {
- this.this$0.treeSelectionModel.resetRowSelection();
- }
- }
- }
-
- }
-
- protected void deepMarkSizeInvalid() {
- this.markSizeInvalid();
-
- for(int var1 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var1 >= 0; --var1) {
- ((VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var1)).deepMarkSizeInvalid();
- }
-
- }
-
- protected void didAdjustTree() {
- }
-
- public void expand() {
- this.expand(true);
- }
-
- protected void expand(boolean var1) {
- if (!this.isExpanded() && !this.isLeaf()) {
- boolean var2 = this.this$0.isFixedRowHeight();
- int var3 = this.getPreferredHeight();
- int var4 = this.getRow();
- this.expanded = true;
- this.updatePreferredSize(var4);
- if (!this.hasBeenExpanded) {
- Object var6 = this.getValue();
- TreeModel var7 = this.this$0.getModel();
- int var8 = var7.getChildCount(var6);
- this.hasBeenExpanded = true;
- if (var4 == -1) {
- for(int var18 = 0; var18 < var8; ++var18) {
- VariableHeightLayoutCache$TreeStateNode var11 = VariableHeightLayoutCache.access$7(this.this$0, var7.getChild(var6, var18));
- ((DefaultMutableTreeNode)this).add(var11);
- var11.updatePreferredSize(-1);
- }
- } else {
- int var9 = var4 + 1;
-
- for(int var10 = 0; var10 < var8; ++var10) {
- VariableHeightLayoutCache$TreeStateNode var5 = VariableHeightLayoutCache.access$7(this.this$0, var7.getChild(var6, var10));
- ((DefaultMutableTreeNode)this).add(var5);
- var5.updatePreferredSize(var9);
- }
- }
- }
-
- int var12 = var4;
- Enumeration var14 = ((DefaultMutableTreeNode)this).preorderEnumeration();
- var14.nextElement();
- int var15;
- if (var2) {
- var15 = 0;
- } else if (this == VariableHeightLayoutCache.access$2(this.this$0) && !this.this$0.isRootVisible()) {
- var15 = 0;
- } else {
- var15 = this.getYOrigin() + this.getPreferredHeight();
- }
-
- if (!var2) {
- while(var14.hasMoreElements()) {
- VariableHeightLayoutCache$TreeStateNode var17 = (VariableHeightLayoutCache$TreeStateNode)var14.nextElement();
- if (!VariableHeightLayoutCache.access$5(this.this$0) && !var17.hasValidSize()) {
- var17.updatePreferredSize(var12 + 1);
- }
-
- var17.setYOrigin(var15);
- var15 += var17.getPreferredHeight();
- Vector var21 = VariableHeightLayoutCache.access$1(this.this$0);
- ++var12;
- var21.insertElementAt(var17, var12);
- }
- } else {
- while(var14.hasMoreElements()) {
- VariableHeightLayoutCache$TreeStateNode var16 = (VariableHeightLayoutCache$TreeStateNode)var14.nextElement();
- Vector var10000 = VariableHeightLayoutCache.access$1(this.this$0);
- ++var12;
- var10000.insertElementAt(var16, var12);
- }
- }
-
- if (var1 && (var4 != var12 || this.getPreferredHeight() != var3)) {
- if (!var2) {
- ++var12;
- if (var12 < this.this$0.getRowCount()) {
- int var20 = var15 - (this.getYOrigin() + this.getPreferredHeight()) + (this.getPreferredHeight() - var3);
-
- for(int var19 = VariableHeightLayoutCache.access$1(this.this$0).size() - 1; var19 >= var12; --var19) {
- ((VariableHeightLayoutCache$TreeStateNode)VariableHeightLayoutCache.access$1(this.this$0).elementAt(var19)).shiftYOriginBy(var20);
- }
- }
- }
-
- this.didAdjustTree();
- VariableHeightLayoutCache.access$8(this.this$0);
- }
-
- if (this.this$0.treeSelectionModel != null) {
- this.this$0.treeSelectionModel.resetRowSelection();
- }
- }
-
- }
-
- protected void expandParentAndReceiver() {
- VariableHeightLayoutCache$TreeStateNode var1 = (VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getParent();
- if (var1 != null) {
- var1.expandParentAndReceiver();
- }
-
- this.expand();
- }
-
- public VariableHeightLayoutCache$TreeStateNode getLastVisibleNode() {
- VariableHeightLayoutCache$TreeStateNode var1;
- for(var1 = this; var1.isExpanded() && ((DefaultMutableTreeNode)var1).getChildCount() > 0; var1 = (VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)var1).getLastChild()) {
- }
-
- return var1;
- }
-
- protected Enumeration getLoadedChildren(boolean var1) {
- if (var1 && !this.hasBeenExpanded) {
- Object var3 = this.getValue();
- TreeModel var4 = this.this$0.getModel();
- int var5 = var4.getChildCount(var3);
- this.hasBeenExpanded = true;
- int var6 = this.getRow();
- if (var6 == -1) {
- for(int var7 = 0; var7 < var5; ++var7) {
- VariableHeightLayoutCache$TreeStateNode var2 = VariableHeightLayoutCache.access$7(this.this$0, var4.getChild(var3, var7));
- ((DefaultMutableTreeNode)this).add(var2);
- var2.updatePreferredSize(-1);
- }
- } else {
- ++var6;
-
- for(int var10 = 0; var10 < var5; ++var10) {
- VariableHeightLayoutCache$TreeStateNode var8 = VariableHeightLayoutCache.access$7(this.this$0, var4.getChild(var3, var10));
- ((DefaultMutableTreeNode)this).add(var8);
- var8.updatePreferredSize(var6++);
- }
- }
-
- return super.children();
- } else {
- return super.children();
- }
- }
-
- public int getModelChildCount() {
- return this.hasBeenExpanded ? super.getChildCount() : this.this$0.getModel().getChildCount(this.getValue());
- }
-
- public Rectangle getNodeBounds(Rectangle var1) {
- if (var1 == null) {
- var1 = new Rectangle(this.getXOrigin(), this.getYOrigin(), this.getPreferredWidth(), this.getPreferredHeight());
- } else {
- var1.x = this.getXOrigin();
- var1.y = this.getYOrigin();
- var1.width = this.getPreferredWidth();
- var1.height = this.getPreferredHeight();
- }
-
- return var1;
- }
-
- public int getPreferredHeight() {
- if (this.this$0.isFixedRowHeight()) {
- return this.this$0.getRowHeight();
- } else {
- if (!this.hasValidSize()) {
- this.updatePreferredSize(this.getRow());
- }
-
- return this.preferredHeight;
- }
- }
-
- public int getPreferredWidth() {
- if (!this.hasValidSize()) {
- this.updatePreferredSize(this.getRow());
- }
-
- return this.preferredWidth;
- }
-
- public int getRow() {
- return VariableHeightLayoutCache.access$1(this.this$0).indexOf(this);
- }
-
- public TreePath getTreePath() {
- return this.path;
- }
-
- public Object getValue() {
- return ((DefaultMutableTreeNode)this).getUserObject();
- }
-
- public int getVisibleChildCount() {
- int var1 = 0;
- if (this.isExpanded()) {
- int var2 = ((DefaultMutableTreeNode)this).getChildCount();
- var1 += var2;
-
- for(int var3 = 0; var3 < var2; ++var3) {
- var1 += ((VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var3)).getVisibleChildCount();
- }
- }
-
- return var1;
- }
-
- public int getXOrigin() {
- if (!this.hasValidSize()) {
- this.updatePreferredSize(this.getRow());
- }
-
- return this.xOrigin;
- }
-
- public int getYOrigin() {
- if (this.this$0.isFixedRowHeight()) {
- int var1 = this.getRow();
- return var1 == -1 ? -1 : this.this$0.getRowHeight() * var1;
- } else {
- return this.yOrigin;
- }
- }
-
- public boolean hasBeenExpanded() {
- return this.hasBeenExpanded;
- }
-
- public boolean hasValidSize() {
- return this.preferredHeight != 0;
- }
-
- public boolean isExpanded() {
- return this.expanded;
- }
-
- public boolean isLeaf() {
- return this.this$0.getModel().isLeaf(this.getValue());
- }
-
- public boolean isVisible() {
- if (this == VariableHeightLayoutCache.access$2(this.this$0)) {
- return true;
- } else {
- VariableHeightLayoutCache$TreeStateNode var1 = (VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getParent();
- return var1 != null && var1.isExpanded() && var1.isVisible();
- }
- }
-
- public void makeVisible() {
- VariableHeightLayoutCache$TreeStateNode var1 = (VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getParent();
- if (var1 != null) {
- var1.expandParentAndReceiver();
- }
-
- }
-
- protected void markSizeInvalid() {
- this.preferredHeight = 0;
- }
-
- public void remove(int var1) {
- VariableHeightLayoutCache$TreeStateNode var2 = (VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var1);
- var2.removeFromMapping();
- super.remove(var1);
- }
-
- protected void removeFromMapping() {
- if (this.path != null) {
- VariableHeightLayoutCache.access$3(this.this$0, this);
-
- for(int var1 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var1 >= 0; --var1) {
- ((VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var1)).removeFromMapping();
- }
- }
-
- }
-
- protected void resetChildrenPaths(TreePath var1) {
- VariableHeightLayoutCache.access$3(this.this$0, this);
- if (var1 == null) {
- this.path = new TreePath(((DefaultMutableTreeNode)this).getUserObject());
- } else {
- this.path = var1.pathByAddingChild(((DefaultMutableTreeNode)this).getUserObject());
- }
-
- VariableHeightLayoutCache.access$0(this.this$0, this);
-
- for(int var2 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var2 >= 0; --var2) {
- ((VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2)).resetChildrenPaths(this.path);
- }
-
- }
-
- public void setParent(MutableTreeNode var1) {
- super.setParent(var1);
- if (var1 != null) {
- this.path = ((VariableHeightLayoutCache$TreeStateNode)var1).getTreePath().pathByAddingChild(((DefaultMutableTreeNode)this).getUserObject());
- VariableHeightLayoutCache.access$0(this.this$0, this);
- }
-
- }
-
- public void setUserObject(Object var1) {
- super.setUserObject(var1);
- if (this.path != null) {
- VariableHeightLayoutCache$TreeStateNode var2 = (VariableHeightLayoutCache$TreeStateNode)((DefaultMutableTreeNode)this).getParent();
- if (var2 != null) {
- this.resetChildrenPaths(var2.getTreePath());
- } else {
- this.resetChildrenPaths((TreePath)null);
- }
- }
-
- }
-
- protected void setYOrigin(int var1) {
- this.yOrigin = var1;
- }
-
- protected void shiftYOriginBy(int var1) {
- this.yOrigin += var1;
- }
-
- public void toggleExpanded() {
- if (this.isExpanded()) {
- this.collapse();
- } else {
- this.expand();
- }
-
- }
-
- protected void updatePreferredSize() {
- this.updatePreferredSize(this.getRow());
- }
-
- protected void updatePreferredSize(int var1) {
- Rectangle var2 = this.this$0.getNodeDimensions(((DefaultMutableTreeNode)this).getUserObject(), var1, ((DefaultMutableTreeNode)this).getLevel(), this.isExpanded(), VariableHeightLayoutCache.access$4(this.this$0));
- if (var2 == null) {
- this.xOrigin = 0;
- this.preferredWidth = this.preferredHeight = 0;
- VariableHeightLayoutCache.access$6(this.this$0, true);
- } else if (var2.height == 0) {
- this.xOrigin = 0;
- this.preferredWidth = this.preferredHeight = 0;
- VariableHeightLayoutCache.access$6(this.this$0, true);
- } else {
- this.xOrigin = var2.x;
- this.preferredWidth = var2.width;
- if (this.this$0.isFixedRowHeight()) {
- this.preferredHeight = this.this$0.getRowHeight();
- } else {
- this.preferredHeight = var2.height;
- }
- }
-
- }
- }
-